<template>
  <window-content class="shop-window" v-if="store" :gutter="10">
    <window-content-col>
      <span>商店</span>
      <div class="scrollbar-row">
        <cg-scrollbar wrap-height="max">
          <div class="gird-content">
            <cg-gird :column="{ gutter: 10, colNum: 1 }">
              <cg-gird-item
                v-for="item in store.shopItems"
                :key="'' + item.id"
                :class="{ 'is-active': selected === item.id }"
                @click="handleSelected(item.id)"
              >
                <div class="gird-item-content">
                  <cg-image :path="item.head_path"></cg-image>
                  <div class="gird-title">{{ item.name }}</div>
                </div>
              </cg-gird-item>
            </cg-gird>
          </div>
        </cg-scrollbar>
      </div>
      <div class="tool-row">
        <cg-button>购买</cg-button>
      </div>
    </window-content-col>
    <window-content-col>
      <span>物品</span>
      <div class="scrollbar-row">
        <cg-scrollbar wrap-height="max">
          <div class="gird-content">
            <cg-gird :column="{ gutter: 10, colNum: 4 }">
              <cg-gird-item
                v-for="item in store.items"
                :key="'' + item.id"
                :class="{ 'is-active': selected === item.id }"
                @click="handleSelected(item.id)"
              >
                <div class="gird-item-content">
                  <cg-image :path="item.head_path"></cg-image>
                  <div class="gird-title">{{ item.name }}</div>
                </div>
              </cg-gird-item>
            </cg-gird>
          </div>
        </cg-scrollbar>
      </div>
      <div class="tool-row">
        <cg-button>卖出</cg-button>
      </div>
    </window-content-col>
  </window-content>
</template>

<script setup lang="ts">
import { ref, inject, type Ref } from 'vue'
import SceneStore from '../sceneStore'
import windowContent from './content.vue'
import windowContentCol from './contentCol.vue'

const store: Ref<SceneStore> | undefined = inject('store')

const selected = ref(undefined)

const handleSelected = (value: any) => {
  selected.value = value
}
</script>

<style lang="scss">
.hire-window {
}
</style>
